﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AppLayer;

namespace GUI
{
	public partial class LogIn : Form
	{
		public delegate void UserAuthenticationEventHandler(UserAccount.UserType type);
		public event UserAuthenticationEventHandler UserAuthenticated;

		UserAccount user;
		UserAccount.UserType userMode = UserAccount.UserType.Normal;

		public LogIn()
		{
			InitializeComponent();
			user = new UserAccount();
		}

		private void submitButton_Click(object sender, EventArgs e)
		{
			//TODO: Test for username and password combo
			userMode = user.LogInUser(userNameTextBox.Text, passwordTextBox.Text);
			//if true then set login type and exit
			if (this.UserAuthenticated != null)
			{
				UserAuthenticated(userMode);
			}
			this.Close();
		}

		private void LogIn_Load(object sender, EventArgs e)
		{
			userNameTextBox.Select();
		}
	}
}
